package com.example;

public class TestStaticMethodInInterface {

    interface Closeable {
        void close();

        static void closeAll(Closeable... closeables){
            for (Closeable closeable : closeables) {
                closeable.close();
                log("something closed");
            }
        }

        // Java9 开始，接口中的静态方法可以是private的
        private static void log(String msg){
            System.out.println(msg);
        }
    }

    public static void main(String[] args) {
        Closeable.closeAll(()->{
            System.out.println("close one");
        }, ()->{
            System.out.println("close two");
        });
    }
}
